package com.irssproject.app.web.interceptor;

import java.util.Map;

import com.irssproject.app.utils.Constants;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AuthorizationInterceptor extends AbstractInterceptor {

    private static final long serialVersionUID = -9199166861711990575L;

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {

        Map session = ActionContext.getContext().getSession();

        if (session.containsKey(Constants.SESSIO_USUARI_AUTENTICAT)) {
            invocation.invoke();
            return Action.SUCCESS;
        } else {
            return "noAutenticat";

        }
    }
}
